

def merge_two_txt_files(in_txt1, in_txt2,out_txt):
    with open(out_txt, "w") as wf:
        with open(in_txt1, "r") as rf:
        
            for line in rf.readlines():
                wf.write(line.replace("code/syn360kcn", "code/syn/syn360kcn") )
        with open(in_txt2, "r") as rf:
        
            for line in rf.readlines():
                wf.write(line.replace("code/syn360kcn", "code/syn/syn360kcn") )
    
if __name__ == "__main__":
    in_txt1 = "/home/swls/work_dir/ocr/code/syn/syn360kcn/labels_new.txt"
    in_txt2 = "/home/swls/work_dir/ocr/code/syn/syn360kcn/labels360k.txt"
    out_txt = "/home/swls/work_dir/ocr/code/syn/syn360kcn/labels.txt"
    merge_two_txt_files(in_txt1, in_txt2,out_txt)